package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysWorkLogOrders;
import com.ruoyi.system.service.ISysWorkLogOrdersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 调度命令Controller
 * 
 * @author ruoyi
 * @date 2023-02-07
 */
@RestController
@RequestMapping("/system/logOrders")
public class SysWorkLogOrdersController extends BaseController
{
    @Autowired
    private ISysWorkLogOrdersService sysWorkLogOrdersService;

    /**
     * 查询调度命令列表
     */
    @PreAuthorize("@ss.hasPermi('system:logOrders:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysWorkLogOrders sysWorkLogOrders)
    {
        startPage();
        List<SysWorkLogOrders> list = sysWorkLogOrdersService.selectSysWorkLogOrdersList(sysWorkLogOrders);
        return getDataTable(list);
    }

    /**
     * 导出调度命令列表
     */
    @PreAuthorize("@ss.hasPermi('system:logOrders:export')")
    @Log(title = "调度命令", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysWorkLogOrders sysWorkLogOrders)
    {
        List<SysWorkLogOrders> list = sysWorkLogOrdersService.selectSysWorkLogOrdersList(sysWorkLogOrders);
        ExcelUtil<SysWorkLogOrders> util = new ExcelUtil<SysWorkLogOrders>(SysWorkLogOrders.class);
        return util.exportExcel(list, "logOrders");
    }

    /**
     * 获取调度命令详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:logOrders:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysWorkLogOrdersService.selectSysWorkLogOrdersById(id));
    }

    /**
     * 新增调度命令
     */
    @PreAuthorize("@ss.hasPermi('system:logOrders:add')")
    @Log(title = "调度命令", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWorkLogOrders sysWorkLogOrders)
    {
        return toAjax(sysWorkLogOrdersService.insertSysWorkLogOrders(sysWorkLogOrders));
    }

    /**
     * 修改调度命令
     */
    @PreAuthorize("@ss.hasPermi('system:logOrders:edit')")
    @Log(title = "调度命令", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWorkLogOrders sysWorkLogOrders)
    {
        return toAjax(sysWorkLogOrdersService.updateSysWorkLogOrders(sysWorkLogOrders));
    }

    /**
     * 删除调度命令
     */
    @PreAuthorize("@ss.hasPermi('system:logOrders:remove')")
    @Log(title = "调度命令", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysWorkLogOrdersService.deleteSysWorkLogOrdersByIds(ids));
    }
}
